Bs (programming Language)
   HOME

TheInfoList



OR:

bs is a programming language and a compiler/interpreter for modest-sized programs on
UNIX Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, ...
systems. The bs command can be invoked either for interactive programming or with a file containing a program, optionally taking arguments, via a
Unix shell A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating syste ...
, e.g., using a
Shebang (Unix) In computing, a shebang is the character sequence consisting of the characters number sign and exclamation mark () at the beginning of a script. It is also called sharp-exclamation, sha-bang, hashbang, pound-bang, or hash-pling. When a text fil ...
#!/usr/bin/bs. An early
man page A man page (short for manual page) is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs (including library and system calls), formal standards and conventions, and e ...
states, " kbd>bsis a remote descendant of
Basic BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College ...
icand SNOBOL4, with a little C thrown in."


History

The bs command appears in UNIX System III Release 3.0 (1980), first released outside of
Bell Labs Nokia Bell Labs, originally named Bell Telephone Laboratories (1925–1984), then AT&T Bell Laboratories (1984–1996) and Bell Labs Innovations (1996–2007), is an American industrial research and scientific development company owned by mul ...
in 1982. It was written by Dick Haight (Richard C. Haight) circa 1978, who recounts it as follows:Personal communication from Dick Haight, 10 September 2019. The Release 3.0 manual mentions bs prominently on page 9 (emphasis added): While not released outside prior to System III, the bs command was present internally in UNIX/TS 1.0 (November 1978),Personal conversation with John R. Mashey, 9 September 2019.
PWB/UNIX The Programmer's Workbench (PWB/UNIX) is an early, now discontinued, version of the Unix operating system that had been created in the Bell Labs Computer Science Research Group of AT&T. Its stated goal was to provide a time-sharing working en ...
2.0 (June 1979), and CB UNIX editions 2.1 (November 1979)"CB/UNIX man 7"
'' The Unix Heritage Society'', November 1979. Retrieved on 9 September 2019.
"CB/UNIX man 1"
'' The Unix Heritage Society'', November 1979. Retrieved on 9 September 2019.
and 2.3 (1981). The bs command does not appear in some earlier internal releases, e.g., the UNIX Support Group’s March 1977 release, nor the PWB/UNIX manual dated May, 1977, suggesting its creation circa 1978. It does not appear in any version of
Research Unix The term "Research Unix" refers to early versions of the Unix operating system for DEC PDP-7, PDP-11, VAX and Interdata 7/32 and 8/32 computers, developed in the Bell Labs Computing Sciences Research Center (CSRC). History The term ''Resear ...
nor the
Berkeley Software Distribution The Berkeley Software Distribution or Berkeley Standard Distribution (BSD) is a discontinued operating system based on Research Unix, developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Be ...
. Subsequently and into the 1990s, bs was included in a variety of System III-derived or System V-derived commercial operating systems including, but not limited to:
PC/IX Interactive Systems Corporation (styled INTERACTIVE Systems Corporation, abbreviated ISC) was a US-based software company and the first vendor of the Unix operating system outside AT&T, operating from Santa Monica, California. It was founded in 19 ...
;
UNIX System V Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
Releases 2 & 3: SVR2,
SVR3 Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
, SVR3.2 (1986);
HP-UX HP-UX (from "Hewlett Packard Unix") is Hewlett Packard Enterprise's proprietary implementation of the Unix operating system, based on Unix System V (initially System III) and first released in 1984. Current versions support HPE Integrity Se ...
;
AIX Aix or AIX may refer to: Computing * AIX, a line of IBM computer operating systems *An Alternate Index, for a Virtual Storage Access Method Key Sequenced Data Set * Athens Internet Exchange, a European Internet exchange point Places Belgiu ...
; and
A/UX A/UX is Apple Computer's Unix-based operating system for Macintosh computers, integrated with System 7's graphical interface and application compatibility. Launched in 1988 and discontinued in 1995 with version 3.1.1, it is Apple's first offic ...
. (The User's Manual for the
AT&T UNIX PC The AT&T UNIX PC is a Unix desktop computer originally developed by Convergent Technologies (later acquired by Unisys), and marketed by AT&T Information Systems in the mid- to late-1980s. The system was codenamed "Safari 4" and is also known as th ...
(3B1) specifically mentions that the bs command is not available, but that it is available on SVR3.2.) Occasionally, bs was touted as one of the primary programming languages for development under UNIX. However, bs is not included in the POSIX.1 commands and utilities (the standard
List of Unix commands This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems. List See also * List of G ...
) nor in the Single UNIX Specification and is not provided with most contemporary operating systems. For example in
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, whi ...
, similar syntax and functionality is provided by bc,
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offic ...
, and
POSIX shell A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating system ...
. In the 21st century, bs is present in, at least,
HP-UX HP-UX (from "Hewlett Packard Unix") is Hewlett Packard Enterprise's proprietary implementation of the Unix operating system, based on Unix System V (initially System III) and first released in 1984. Current versions support HPE Integrity Se ...
Release 11i (2000), as well as
AIX Aix or AIX may refer to: Computing * AIX, a line of IBM computer operating systems *An Alternate Index, for a Virtual Storage Access Method Key Sequenced Data Set * Athens Internet Exchange, a European Internet exchange point Places Belgiu ...
versions 6.1 (2007) and 7.2 (2018), likely due to their
UNIX System V Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
heritage.


Design and features

The bs
man page A man page (short for manual page) is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs (including library and system calls), formal standards and conventions, and e ...
, ostensibly the programming language's only specification, characterizes it as follows: A bs program is compiled and executed differently from programs written in the other principal Unix programming languages of the time: C, FORTRAN, and
assembly language In computer programming, assembly language (or assembler language, or symbolic machine code), often referred to simply as Assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence b ...
, whose respective commands compile program source code to executable assembler output (
a.out a.out is a file format used in older versions of Unix-like computer operating systems for executables, object code, and, in later systems, shared libraries. This is an abbreviated form of "assembler output", the filename of the output of Ken T ...
). Instead, a bs program is, first, converted by the bs command to an internal reverse Polish ( RPN)
intermediate representation An intermediate representation (IR) is the data structure or code used internally by a compiler or virtual machine to represent source code. An IR is designed to be conducive to further processing, such as optimization and translation. A "good" ...
and then executed by the command's internal virtual
stack machine In computer science, computer engineering and programming language implementations, a stack machine is a computer processor or a virtual machine in which the primary interaction is moving short-lived temporary values to and from a push down ...
. The bs language, thus, is a hybrid interpreter and
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs tha ...
and a divergence in
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, ...
programming from
Ancient Unix Ancient UNIX is any early release of the Unix code base prior to Unix System III, particularly the Research Unix releases prior to and including Version 7 (the base for UNIX/32V as well as later developments of AT&T Unix). After the publica ...
. The bs language shares some features and syntax with
BASIC BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College ...
,
SNOBOL SNOBOL ("StriNg Oriented and symBOlic Language") is a series of programming languages developed between 1962 and 1967 at AT&T Bell Laboratories by David J. Farber, Ralph E. Griswold and Ivan P. Polonsky, culminating in SNOBOL4. It was one of ...
, and C, the two former presumably inspiring its name. Like BASIC, it can be used interactively, either executing statements immediately or collecting them into a program to be executed subsequently. Like in SNOBOL4, the assignment operator (=) is used for I/O and bs can execute code in strings, using its eval function. It also includes SNOBOL's interrogation operator (?) used to test whether an expression evaluation succeeds or not. The built-in format function, limited to one argument, supports a subset of C's printf format conversion specifiers, e.g., "%f". The language has some conspicuous elements. For instance, its program functions are defined using the fun ... nuf syntax and its functions can have local variables. Also, bs can operate in two modes, either interpreting (and executing) statements and programs or compiling them, and switching between the two using compile and stop. Otherwise, its functionality is unique only collectively (in one language), since individual features are redundant with those of coexisting tools, such as the
Unix Shell A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating syste ...
, e.g., file I/O and loops, and AWK, e.g., associative arrays and
Regular expression A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
matching. The bs language was meant for convenient development and debugging of small, modular programs. It has a collection of syntax and features from prior, popular languages but it is internally compiled, unlike a
Shell script A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file man ...
. As such, in purpose, design, and function, bs is a largely unknown, modest predecessor of hybrid interpreted/compiled languages such as
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offic ...
and Python.


Syntax Examples

''The following examples are derived from an A/UX bs(1)
man page A man page (short for manual page) is a form of software documentation usually found on a Unix or Unix-like operating system. Topics covered include computer programs (including library and system calls), formal standards and conventions, and e ...
.'' This example uses bs as a calculator: This example is the outline of a typical bs program: This example demonstrates I/O:


Sample Program

''The following is a sample bs program that emits the words to the song
99 Bottles of Beer "99 Bottles of Beer" or "100 Bottles of Pop on the Wall" is a song dating to the mid-20th century. It is a traditional reverse counting song in both the United States and Canada. It is popular to sing on road trips, as it has a very repetitive ...
using /usr/bin/bs.'' "Language BS"
''
99 Bottles of Beer "99 Bottles of Beer" or "100 Bottles of Pop on the Wall" is a song dating to the mid-20th century. It is a traditional reverse counting song in both the United States and Canada. It is popular to sing on road trips, as it has a very repetitive ...
'', 8 August 1996. Retrieved on 9 September 2019.


See also

* dc * bc


References

{{cite magazine , magazine=PC Magazine , date=June 12, 1984 , title=IBM Goes UNIX , page=218 The /FILES file, A/UX 3.0.1 installation media, Apple Inc. (1993) Programming languages Unix_programming_tools